<?php 
//提供返回按钮所需的参数
$backData = array('cooker' => 'BWPProduct@ShowHome');
echo $control->renderView("header",array('backData' => $backData, 'title' => '涵信产品'));
?>
<!--******************** News Section ********************-->
<section id="news" class="single-page scrollblock">
  <div class="container">
    <!-- Three columns -->
    <div class="row">
        <?php
        foreach ($productView as $productList) {
            //获取产品的基础信息
            $productAlias = $productList->getItem('alias')->getValue();
            $descriptionItem = $productList->getItem('description');
            if ($descriptionItem != NULL) {
                $productDescription = $descriptionItem->getValue();
            }
            
            //根据产品的list获取产品的各个属性
            $attributeTable = new BASheet('productAttribute', $productList);
            $attributeView = $attributeTable->getView();
            //用于存储产品除图片外的其他属性
            $attributeArr = array();

            foreach ($attributeView as $attribute) {
                $nameItem = $attribute->getItem('name');    //属性名的item 英文
                $typeItem = $attribute->getItem('type');    //属性的类型的item image string
                $aliasItem = $attribute->getItem('alias');  //属性的别名的item
                $name = '';
                $type = '';
                $alias = '';
                if ($nameItem instanceof BTreeItem) {
                    $name = $nameItem->getValue();
                }
                if ($aliasItem instanceof BTreeItem) {
                    $alias = $aliasItem->getValue();
                }
                if ($typeItem instanceof BTreeItem) {
                    $type = $typeItem->getValue();
                    //判断类型是不是图片
                    if ($type == 'image'){
                        $attributeItem = $productList->getItem($name);
                        if ($attributeItem instanceof BTreeItem) {
                            $attributeValue = $attributeItem->getValue();
                            $productImage = Yii::app()->request->baseUrl . $attributeValue;
                        }
                    } else {
                        $attributeItem = $productList->getItem($name);
                        if ($attributeItem instanceof BTreeItem) {
                            $attributeValue = $attributeItem->getValue();
                            $attributeArr[$alias] = $attributeValue;
                        }
                    }
                }
            }
            ?>
            <article class="span4 post">
                <div style="margin:0 auto">
                    <img class="img-news" style="width:100%;" src="<?php 
                        if (isset($productImage)) {
                            echo $productImage;
                        } else {
                            echo Yii::app()->request->baseUrl.'/images/mobile/no_picture.gif';
                        }
                        ?>" alt="">
                </div>
                <div class="inside">
                  <h2><?php echo $productAlias;?></h2>
                  <div class="entry-content">
                        <p>
                        <?php
                        foreach ($attributeArr as $key => $value) {
                            echo $key . '：' . $value .'；';
                        }
                        echo '<br/>';
                        if (isset($productDescription)) {
                            echo $productDescription;
                        }
                        ?>
                        </p>
                  </div>
                </div>
                <!-- /.inside -->
            </article>
        <?php } ?>
      <!-- /.span4 -->
    </div>
    <!-- /.row -->
  <!-- /.container -->
</section>
<?php 
echo $control->renderView("footer");
?>